﻿/******************************************************   
创建者: 梁家健
创建时间: 2017-05-04
修改:
修改时间: 
功能: 企划唯一码报表导出
 ******************************************************/

using com.nm.library.Excels;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using NDF.Utilities;

namespace PlanAPI.Export
{
    [Export(typeof(ExcelImport))]
    public class PLOnlyCode : ExcelImport
    {
        public override ExcelImportType Type => ExcelImportType.PLONLYCODE;
        public override Dictionary<string, ImportVerify> DictFields => _dictFields;

        private Dictionary<string, ImportVerify> _dictFields = new List<ImportVerify> {
            new ImportVerify{ ColumnName="年份",FieldName="Yearv",DataType=typeof(long),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="月份",FieldName="Monthv",DataType=typeof(long),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="周",FieldName="Weekv",DataType=typeof(long),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="商品区域",FieldName="ParentAreaName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="店铺",FieldName="ShopName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="类别",FieldName="KindName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="系列",FieldName="SeriesName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="商品层",FieldName="MaterialProperty",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="品类",FieldName="ModelName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="小品类",FieldName="ItemName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="唯一码",FieldName="OnlyCode",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,false,true)},
            new ImportVerify{ ColumnName="深度",FieldName="DeepQty",DataType=typeof(long),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,false,true)},
            new ImportVerify{ ColumnName="是否流行色",FieldName="ChooseFlag",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,50,false,true)},
           }.ToDictionary(e => e.ColumnName, e => e);

        public override object SaveImportData(DataTable dt, Dictionary<string, object> extraInfo, int userId)
        {
            throw new NotImplementedException();
        }

        public override DataTable GetExportData(string Keys)
        {
            var list = Keys.Split("other.");
            var CodeOrShop = list[1].Contains("isShop") ? 1L : 0L;
            var handler = new PLOnlyCodeHandler();
            return handler.ExportPLOnlyCode(list[0].Substring(0, list[0].Length - 4), CodeOrShop);
        }
    }
}
